﻿using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2025-02-22
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 子篮记录
    /// </summary>
    [Verify]
    [Route("business/CksBasketrecord")]
    [ApiExplorerSettings(GroupName = "business")]
    public class CksBasketrecordController : BaseController
    {
        /// <summary>
        /// 子篮记录接口
        /// </summary>
        private readonly ICksBasketrecordService _CksBasketrecordService;

        public CksBasketrecordController(ICksBasketrecordService CksBasketrecordService)
        {
            _CksBasketrecordService = CksBasketrecordService;
        }

        /// <summary>
        /// 查询子篮记录列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "CksBasketrecord:list")]
        public IActionResult QueryCksBasketrecord([FromQuery] CksBasketDyneRecordQueryDto parm)
        {
            var response = _CksBasketrecordService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询子篮记录详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "CksBasketrecord:query")]
        public IActionResult GetCksBasketrecord(long Id)
        {
            var response = _CksBasketrecordService.GetInfo(Id);

            var info = response.Adapt<CksBasketDyneRecordDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加子篮记录
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "CksBasketrecord:add")]
        [Log(Title = "子篮记录", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCksBasketrecord([FromBody] CksBasketDyneRecordDto parm)
        {
            var modal = parm.Adapt<CksBasketDyneRecord>().ToCreate(HttpContext);

            var response = _CksBasketrecordService.AddCksBasketrecord(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新子篮记录
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "CksBasketrecord:edit")]
        [Log(Title = "子篮记录", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCksBasketrecord([FromBody] CksBasketDyneRecordDto parm)
        {
            var modal = parm.Adapt<CksBasketDyneRecord>().ToUpdate(HttpContext);
            var response = _CksBasketrecordService.UpdateCksBasketrecord(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除子篮记录
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "CksBasketrecord:delete")]
        [Log(Title = "子篮记录", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCksBasketrecord([FromRoute] string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_CksBasketrecordService.Delete(idArr));
        }

    }
}